diff --git a/django/db/migrations/loader.py b/django/db/migrations/loader.py
index 95a5062ec9..ab8925afa2 100644
--- a/django/db/migrations/loader.py
+++ b/django/db/migrations/loader.py
@@ -88,13 +88,8 @@ class MigrationLoader:
                     continue
                 raise
             else:
-                # Empty directories are namespaces.
-                # getattr() needed on PY36 and older (replace w/attribute access).
-                if getattr(module, '__file__', None) is None:
-                    self.unmigrated_apps.add(app_config.label)
-                    continue
-                # Module is not a package (e.g. migrations.py).
-                if not hasattr(module, '__path__'):
+                # Check if the module has a __file__ attribute or a non-namespace __path__ attribute.
+                if getattr(module, '__file__', None) is None and not (hasattr(module, '__path__') and isinstance(module.__path__, list)):
                     self.unmigrated_apps.add(app_config.label)
                     continue
                 # Force a reload if it's already loaded (tests need this)
